/**
 * Created by liubin on 2014/8/31.
 */
/**
 * 控制器初始化
 */
define(['angular'], function (angular) {
    'use strict';
    return angular.module('app.controllers', []).
        controller('main', ['$scope', '$location', function($scope, $location){
            $scope.main = {
                title: '集修哥后台管理'
            }
            $scope.isMenuActive = function (viewLocation) {
                if(viewLocation == 'index'){
                    return '/' == $location.path();
                }
                else{
                    return $location.path().indexOf(viewLocation) == 0;
                }
            };
            var menuStyle = {
                '/html/user' : 'system',
                '/html/role' : 'system'
            };
            $scope.getMenuStyle = function (viewLocation) {
                    var parent = menuStyle[viewLocation];
                var value;
                var key;
                for(key in menuStyle){
                    console.log('for');
                    console.log(key);
                    console.log($location.path());
                    if($location.path().indexOf(key) == 0){
                        value = menuStyle[key];
                        break;
                    }
                }
                console.log(viewLocation);
                console.log(value);
                console.log(parent);
                if(value == parent){
                    return {
                        display: 'block'
                    };
                }
                else{
                    return {
                        display: 'none'
                    }
                }
            }
        }]).controller('modalCtrl', ['$scope', '$modalInstance', 'title', 'content',
            function($scope, $modalInstance, title, content){
            $scope.title = title;
            $scope.content = content;
            $scope.ok = function () {
                $modalInstance.close();
            };
            $scope.cancel = function () {
                $modalInstance.dismiss('cancel');
            };
        }]);
});